package com.zzyl.nursing.controller.member;



import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.nursing.domain.MyList;
import com.zzyl.nursing.dto.*;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.*;
import com.zzyl.nursing.vo.health.IdentifierVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 *
 * @author ruoyi
 * @date 2025-04-26
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
@Slf4j
public class FamilyMemberController extends BaseController {
    @Autowired
    private IFamilyMemberService familyMemberService;

    @PostMapping("/login")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo vo = familyMemberService.login(dto);
        return success(vo);
    }

    @PostMapping("/add")
    public AjaxResult add(@RequestBody FamilyMemberElderDto familyMemberElderDto) {
        familyMemberService.add(familyMemberElderDto);
        return success();
    }

    @GetMapping("/my")
    public AjaxResult my(){
      List<FamilyMemberElderVo> familyMemberElderVo = familyMemberService.my();
        return success(familyMemberElderVo);
    }

    @GetMapping("/list-by-page")
    @ApiOperation("分页查询家人列表")
    public R<List<ElderDateVo>> listByPage(Integer pageNum, Integer pageSize){
        startPage(pageNum, pageSize);
        List<ElderDateVo> list = familyMemberService.getFamilyList();
        return R.ok(list);
    }

    @PostMapping("/QueryDevicePropertyStatus")
    @ApiOperation("查询健康数据")
    public R<DeviceDateStatusListVo> QueryDevicePropertyStatus(@RequestBody DevicePropertyDto devicePropertyDto){
        DeviceDateStatusListVo list = familyMemberService.getDevicePropertyStatus(devicePropertyDto);
        return R.ok(list);
    }

    @GetMapping("/queryDeviceDataListByDay")
    @ApiOperation("按天统计查询指标数据")
    public R<List<DeviceDataListVo>> queryDeviceDataListByDay(DeviceDataListDto deviceDataListDto){
        List<DeviceDataListVo> list = familyMemberService.queryDeviceDataListByDay(deviceDataListDto);
        return R.ok(list);
    }

    @GetMapping("/queryDeviceDataListByWeek")
    @ApiOperation("按周统计查询指标数据")
    public R<List<DeviceDataListVo>> queryDeviceDataListByWeek(DeviceDataListDto deviceDataListDto){
        List<DeviceDataListVo> list = familyMemberService.queryDeviceDataListByWeek(deviceDataListDto);
        return R.ok(list);
    }
}
